﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.LIB.YJKControls;
using YArchitech.Revit;

namespace ElectricDim
{
	public partial class DlgBoxNumDim : DlgModelLess
	{
		public static DlgBoxNumDim GetInstance(UIApplication app, WindowHandle handel)
		{
			if (DlgBoxNumDim.dll == null || DlgBoxNumDim.dll.IsDisposed)
			{
				DlgBoxNumDim.dll = new DlgBoxNumDim(app, handel);
			}
			return DlgBoxNumDim.dll;
		}

        public Autodesk.Revit.DB.ElementType GetElementType()
		{
            Autodesk.Revit.DB.ElementType result = null;
			using (List<FamilySymbol>.Enumerator enumerator = ElectricMark.SwitchBoxMark(this.mApp.ActiveUIDocument.Document)[0].LoadInSubTrans(this.mApp.ActiveUIDocument.Document).GetSymbols().GetEnumerator())
			{
				if (enumerator.MoveNext())
				{
					result = enumerator.Current;
				}
			}
			return result;
		}

		public LabelType GetLabelType()
		{
			if (this.rbFromWire.Checked)
			{
				return LabelType.FromObject;
			}
			return LabelType.FromText;
		}

		public string Label
		{
			get
			{
				return this.txtInput.Text;
			}
		}

		public LeaderStyle GetDimStyle()
		{
			if (this.rbNullLeader.Checked)
			{
				return LeaderStyle.None;
			}
			if (this.rbHasLeader.Checked)
			{
				return LeaderStyle.HasLeader;
			}
			return LeaderStyle.Orthogonal;
		}

		public PointStyle GetDimLinkStyle()
		{
			if (this.rbNull.Checked)
			{
				return PointStyle.None;
			}
			if (this.rbArrow.Checked)
			{
				return PointStyle.Arrow;
			}
			return PointStyle.Circle;
		}

		public DlgBoxNumDim(UIApplication app, WindowHandle handle) : base(handle)
		{
			this.mApp = app;
			this.InitializeComponent();
		}

		private void rbNullLeader_CheckedChanged(object sender, EventArgs e)
		{
			this.groupBox3.Enabled = !this.rbNullLeader.Checked;
		}

		private void rbFromWire_CheckedChanged(object sender, EventArgs e)
		{
			this.txtInput.Enabled = !this.rbFromWire.Checked;
		}

		private void rbCircle_CheckedChanged(object sender, EventArgs e)
		{
		}

		private static DlgBoxNumDim dll;

		private UIApplication mApp;
	}
}
